/*
ID: icerupt1
PROG: lgame
LANG: C++11
*/

/* solution
 *
 * great.
 * 题目不错，不过因为字符串比较短，可以暴力枚举2^7的字符情况，为了处理一对单词，
 * 枚举前一个单词，二分后一个单词。。不过输出各种问题，，代码很长。
 *
*/

#include <fstream>
#include <iostream>
#include <algorithm>
#include <vector>
#include <iterator>
#include <utility>
#include <string>
#include <unordered_map>

std::ifstream dict_in{"lgame.dict" };
std::ifstream 	  fin{"lgame.in" };
std::ofstream 	 fout{"lgame.out"};

struct string_pos { std::string s; int pos; };

bool operator<(string_pos const & a, string_pos const & b)
{
	return a.s < b.s;
}

bool operator<(string_pos const & a, std::string const & b)
{
	return a.s < b;
}

bool operator<(std::string const & a, string_pos const & b)
{
	return a < b.s;
}

std::vector<string_pos> dict;
std::vector<string_pos> sorted_dict;
std::unordered_map<char, int> button{
										{'q', 7}, {'w', 6}, {'e', 1}, {'r', 2}, {'t', 2},
										{'y', 5}, {'u', 4}, {'i', 1}, {'o', 3}, {'p', 5},
										{'a', 2}, {'s', 1}, {'d', 4}, {'f', 6}, {'g', 5},
										{'h', 5}, {'j', 7}, {'k', 6}, {'l', 3}, {'z', 7},
										{'x', 7}, {'c', 4}, {'v', 6}, {'b', 5}, {'n', 2},
										{'m', 5},
									};

void init_dict()
{
	int p = 0;
	for (std::string i; dict_in >> i && i != "."; p++) {
		dict.push_back({i, p});
		std::sort(i.begin(), i.end());
		sorted_dict.push_back({i, p});
	}
	std::sort(sorted_dict.begin(), sorted_dict.end());
	for (auto i = 0; i < (int)sorted_dict.size(); i++)
		dict[sorted_dict[i].pos].pos = i;
}

auto calc(std::string s)
{
	int score = 0;
	for (auto c : s) score += button[c];
	return score;
}

auto difference(std::string const & a, std::string const & b)
{
	std::string diff;
	std::set_difference(a.begin(), a.end(), b.begin(), b.end(),
								std::inserter(diff, diff.begin()));
	return diff;
}

auto includes(std::string const & a, std::string const & b)
{
	return std::includes(a.begin(), a.end(), b.begin(), b.end());
}

auto select_out(std::string const & s, int x)
{
	std::string tmp;
	for (int i = 0; x; x /= 2, i++)
		if (x&1) tmp += s[i];
	return tmp;
}

auto max_pair(std::string s)
{
	for (int i = 0; i < (int)dict.size(); i++) {
		if (!includes(s, sorted_dict[dict[i].pos].s)) continue;
		std::string part2 = difference(s, sorted_dict[dict[i].pos].s);

		int move = dict[i].pos + 1;
		auto it_u = std::upper_bound(sorted_dict.begin() + move, sorted_dict.end(), part2);
		auto it_l = std::lower_bound(sorted_dict.begin() + move, sorted_dict.end(), part2);
		if (it_u - it_l > 0) return calc(s);
	}
	return 0;
}

std::vector<std::string> dest_pair;

auto get_max_score(std::string const & s)
{
	int max = 0;
	for (int i = 0; i < (int)dict.size(); i++)
		if (includes(s, sorted_dict[dict[i].pos].s)) max = std::max(max, calc(dict[i].s));

	//words pair
	int len = s.size();
	for (int i = 1; i < (1<<len); i++) {
		std::string tmp = select_out(s, i);
		std::sort(tmp.begin(), tmp.end());
		int tmp_m = max_pair(tmp);
		if (tmp_m >= max) {
			max = tmp_m;
		}
	}

	for (int i = 1; i < (1<<len); i++) {
		std::string tmp = select_out(s, i);
		std::sort(tmp.begin(), tmp.end());
		int tmp_m = max_pair(tmp);
		if (tmp_m == max)
			dest_pair.push_back(tmp);
	}

	return max;
}

int main()
{
	init_dict();
	std::string s;
	fin >> s;
	std::sort(s.begin(), s.end());
	int max_score = get_max_score(s);

	std::cout << max_score << '\n';
	fout << max_score << '\n';
	std::vector<std::pair<std::string, std::string>> ans;
	for (int i = 0; i < (int)dict.size(); i++) {
		if (!includes(s, sorted_dict[dict[i].pos].s)) continue;
		if (calc(dict[i].s) == max_score)
			ans.push_back({dict[i].s, ""});
	}

	for (auto dest : dest_pair) {
		for (int i = 0; i < (int)sorted_dict.size(); i++) {
			if (!includes(dest, sorted_dict[i].s)) continue;
			std::string part2 = difference(dest, sorted_dict[i].s);

			int move = i + 1;
			auto it_u = std::upper_bound(sorted_dict.begin() + move, sorted_dict.end(), part2);
			auto it_l = std::lower_bound(sorted_dict.begin() + move, sorted_dict.end(), part2);

			for (auto it = it_l; it != it_u; ++it) {
				std::string s1 = dict[sorted_dict[i].pos].s;
				std::string s2 = dict[(*it).pos].s;
				if (s1 > s2) std::swap(s1, s2);
				ans.push_back({s1, s2});
			}
		}
	}

	std::sort(ans.begin(), ans.end());
	for (auto a : ans) {
		std::cout << a.first;
		if (a.second != "") std::cout << ' ' << a.second;
		std::cout << '\n';

		fout << a.first;
		if (a.second != "") fout << ' ' << a.second;
		fout << '\n';
	}
}

